package com.matrix.java.chap_03;

import java.util.Scanner;

/*
    金融：货币兑換
 */
public class Ex3_31 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter the exchange rate from dollars to RMB: ");
        double rate = input.nextDouble();
        System.out.print("Enter 0 to convert dollars to RMB and 1 vice versa: ");
        int num = input.nextInt();
        System.out.print("Enter the dollar amount or RMB amount: ");
        double amount = input.nextDouble();
        switch (num){
            case 0:amount*=rate;break;
            case 1:amount/=rate;break;
        }
        System.out.println(String.format("%.2f", amount).toString());
        input.close();
    }
}
